package cn.usian.service.impl;

import cn.usian.dao.EmpMapper;
import cn.usian.pojo.Emp;
import cn.usian.service.EmpService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class EmpServiceImpl implements EmpService {
    @Resource
    private EmpMapper empMapper;

    public Page<Emp> findPage(String name, Integer pageNum) {
        LambdaQueryWrapper<Emp> queryWrapper = new LambdaQueryWrapper<Emp>();
        return empMapper.selectPage(new Page<Emp>(pageNum,2),queryWrapper);
    }



    public void add(Emp emp) {
        empMapper.insert(emp);
    }

    public void edit(Emp emp) {
        empMapper.updateById(emp);
    }

    public Emp findById(int id) {
        return empMapper.selectById(id);
    }



    public void del(int id) {
        empMapper.deleteById(id);
    }
}
